




/*
'===============================================================================
'  MP.LayerHelper.MP_OBS.BL.MenuManagerBase
'===============================================================================
*/

using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using MP.LayerHelper.MP_OBS.BLL;
using MP.LayerHelper.MP_OBS.DAL;
using MP.LayerHelper.MP_OBS.DAL.EntityClasses;
using MP.LayerHelper.MP_OBS.DAL.FactoryClasses;
using MP.LayerHelper.MP_OBS.DAL.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

namespace MP.LayerHelper.MP_OBS.BLL
{
	public class MenuManagerBase : ManagerBase
	{
		/// <summary>
		/// Purpose: Class constructor.
		/// </summary>
		
		public MenuManagerBase()
		{
			// Nothing for now.
		}
		
		public override string TableName()
        {
            return "Menu";
        }
		
		public MenuEntity Insert(MenuEntity _MenuEntity)
		{
			return Insert(_MenuEntity, "");
		}
		
		public MenuEntity Insert(MenuEntity _MenuEntity, string controlId)
		{
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.SaveEntity(_MenuEntity, true);
				MenuFields field = new MenuFields();
                LogEntity(_MenuEntity, field, AcInsert, controlId);
			}
			return _MenuEntity;
		}

		
		public MenuEntity Insert(string Id, string MenuName, string Url, string RootId, string ParentId, int OrderIndex, string ModCode, bool IsEnable, string Action, Guid Rowguid)
		{
			MenuEntity _MenuEntity = new MenuEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_MenuEntity.Id = Id;
				_MenuEntity.MenuName = MenuName;
				_MenuEntity.Url = Url;
				_MenuEntity.RootId = RootId;
				_MenuEntity.ParentId = ParentId;
				_MenuEntity.OrderIndex = OrderIndex;
				_MenuEntity.ModCode = ModCode;
				_MenuEntity.IsEnable = IsEnable;
				_MenuEntity.Action = Action;
				_MenuEntity.Rowguid = Rowguid;
				MenuFields field = new MenuFields();
                LogEntity(_MenuEntity, field, AcInsert);
				adapter.SaveEntity(_MenuEntity, true);
			}
			return _MenuEntity;
		}

		public MenuEntity Insert(string MenuName, string Url, string RootId, string ParentId, int OrderIndex, string ModCode, bool IsEnable, string Action, Guid Rowguid)
		{
			MenuEntity _MenuEntity = new MenuEntity();
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				
				_MenuEntity.MenuName = MenuName;
				_MenuEntity.Url = Url;
				_MenuEntity.RootId = RootId;
				_MenuEntity.ParentId = ParentId;
				_MenuEntity.OrderIndex = OrderIndex;
				_MenuEntity.ModCode = ModCode;
				_MenuEntity.IsEnable = IsEnable;
				_MenuEntity.Action = Action;
				_MenuEntity.Rowguid = Rowguid;
				adapter.SaveEntity(_MenuEntity, true);
				MenuFields field = new MenuFields();
                LogEntity(_MenuEntity, field, AcInsert);
			}
			return _MenuEntity;
		}
		
		public bool Update(MenuEntity _MenuEntity)
        {
            return Update(_MenuEntity, "");
        }

		public bool Update(MenuEntity _MenuEntity, string controlId)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				RelationPredicateBucket filter = new RelationPredicateBucket();
				IPredicateExpression _PredicateExpression = new PredicateExpression();
				_PredicateExpression.Add(MenuFields.Id == _MenuEntity.Id);
					
				filter.PredicateExpression.Add(_PredicateExpression);

				adapter.UpdateEntitiesDirectly(_MenuEntity, filter);
				toReturn = true;
				
				MenuFields field = new MenuFields();
                LogEntity(_MenuEntity, field, AcUpdate, controlId);
			}
			return toReturn;
		}
		
		public bool Update(MenuEntity _MenuEntity, RelationPredicateBucket filter)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.UpdateEntitiesDirectly(_MenuEntity, filter);
				toReturn = true;
				
				MenuFields field = new MenuFields();
                LogEntity(_MenuEntity, field, AcUpdate);
			}
			return toReturn;
		}

		public bool Update(string Id, string MenuName, string Url, string RootId, string ParentId, int OrderIndex, string ModCode, bool IsEnable, string Action, Guid Rowguid)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MenuEntity _MenuEntity = new MenuEntity(Id);
				if (adapter.FetchEntity(_MenuEntity))
				{
				
					_MenuEntity.MenuName = MenuName;
					_MenuEntity.Url = Url;
					_MenuEntity.RootId = RootId;
					_MenuEntity.ParentId = ParentId;
					_MenuEntity.OrderIndex = OrderIndex;
					_MenuEntity.ModCode = ModCode;
					_MenuEntity.IsEnable = IsEnable;
					_MenuEntity.Action = Action;
					_MenuEntity.Rowguid = Rowguid;
					adapter.SaveEntity(_MenuEntity, true);
					toReturn = true;
					
					MenuFields field = new MenuFields();
					LogEntity(_MenuEntity, field, AcUpdate);
				}
			}
			return toReturn;
		}

		public bool Delete(string Id)
		{
			bool toReturn = false;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MenuEntity _MenuEntity = new MenuEntity(Id);
				if (adapter.FetchEntity(_MenuEntity))
				{
					adapter.DeleteEntity(_MenuEntity);
					toReturn = true;
				}
			}
			return toReturn;
		}
		
		public void DeleteAll() 
		{
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.DeleteEntitiesDirectly("MenuEntity", null);
			}
		}
		
		
		public int DeleteById(string Id)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByMenuName(string MenuName)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.MenuName == MenuName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByUrl(string Url)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Url == Url);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByRootId(string RootId)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.RootId == RootId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByParentId(string ParentId)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.ParentId == ParentId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByOrderIndex(int OrderIndex)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.OrderIndex == OrderIndex);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByModCode(string ModCode)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.ModCode == ModCode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByIsEnable(bool IsEnable)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByAction(string Action)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Action == Action);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MenuEntity", filter);
			}
			return toReturn;
		}
		
		public int DeleteByRowguid(Guid Rowguid)
		{
			int toReturn = 0;
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Rowguid == Rowguid);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				toReturn = adapter.DeleteEntitiesDirectly("MenuEntity", filter);
			}
			return toReturn;
		}
		

		
		public MenuEntity SelectOne(string Id)
		{
			MenuEntity toReturn = null;
			using(DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				MenuEntity _MenuEntity = new MenuEntity(Id);
				if (adapter.FetchEntity(_MenuEntity))
				{
					toReturn = _MenuEntity;
				}
			}
			return toReturn;
		}

		// Return DataTable
		public DataTable SelectAllRDT()
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, null, true);
			}
			return toReturn;
		}
		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectAllLST()
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, null, 0, null);
			}
			return _MenuCollection;
		}
		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectAllLST_Paged(int PageNumber, int PageSize)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, null, 0, null, null, PageNumber, PageSize);
			}
			return _MenuCollection;
		}


		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByIdLST(string Id)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null);
			}
			return _MenuCollection;
		}
		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByIdLST_Paged(string Id, int PageNumber, int PageSize)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIdRDT(string Id)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByIdRDT_Paged(string Id, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Id == Id);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByMenuNameLST(string MenuName)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.MenuName == MenuName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null);
			}
			return _MenuCollection;
		}
		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByMenuNameLST_Paged(string MenuName, int PageNumber, int PageSize)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.MenuName == MenuName);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByMenuNameRDT(string MenuName)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.MenuName == MenuName);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByMenuNameRDT_Paged(string MenuName, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.MenuName == MenuName);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByUrlLST(string Url)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Url == Url);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null);
			}
			return _MenuCollection;
		}
		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByUrlLST_Paged(string Url, int PageNumber, int PageSize)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Url == Url);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByUrlRDT(string Url)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Url == Url);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByUrlRDT_Paged(string Url, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Url == Url);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByRootIdLST(string RootId)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.RootId == RootId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null);
			}
			return _MenuCollection;
		}
		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByRootIdLST_Paged(string RootId, int PageNumber, int PageSize)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.RootId == RootId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByRootIdRDT(string RootId)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.RootId == RootId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByRootIdRDT_Paged(string RootId, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.RootId == RootId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByParentIdLST(string ParentId)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.ParentId == ParentId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null);
			}
			return _MenuCollection;
		}
		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByParentIdLST_Paged(string ParentId, int PageNumber, int PageSize)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.ParentId == ParentId);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByParentIdRDT(string ParentId)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.ParentId == ParentId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByParentIdRDT_Paged(string ParentId, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.ParentId == ParentId);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByOrderIndexLST(int OrderIndex)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.OrderIndex == OrderIndex);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null);
			}
			return _MenuCollection;
		}
		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByOrderIndexLST_Paged(int OrderIndex, int PageNumber, int PageSize)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.OrderIndex == OrderIndex);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByOrderIndexRDT(int OrderIndex)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.OrderIndex == OrderIndex);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByOrderIndexRDT_Paged(int OrderIndex, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.OrderIndex == OrderIndex);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByModCodeLST(string ModCode)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.ModCode == ModCode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null);
			}
			return _MenuCollection;
		}
		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByModCodeLST_Paged(string ModCode, int PageNumber, int PageSize)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.ModCode == ModCode);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByModCodeRDT(string ModCode)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.ModCode == ModCode);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByModCodeRDT_Paged(string ModCode, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.ModCode == ModCode);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByIsEnableLST(bool IsEnable)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null);
			}
			return _MenuCollection;
		}
		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByIsEnableLST_Paged(bool IsEnable, int PageNumber, int PageSize)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByIsEnableRDT(bool IsEnable)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByIsEnableRDT_Paged(bool IsEnable, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.IsEnable == IsEnable);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByActionLST(string Action)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Action == Action);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null);
			}
			return _MenuCollection;
		}
		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByActionLST_Paged(string Action, int PageNumber, int PageSize)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Action == Action);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByActionRDT(string Action)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Action == Action);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByActionRDT_Paged(string Action, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Action == Action);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByRowguidLST(Guid Rowguid)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Rowguid == Rowguid);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null);
			}
			return _MenuCollection;
		}
		
		// Return EntityCollection<MenuEntity>
		public EntityCollection<MenuEntity> SelectByRowguidLST_Paged(Guid Rowguid, int PageNumber, int PageSize)
		{
			EntityCollection<MenuEntity> _MenuCollection = new EntityCollection<MenuEntity>();
			RelationPredicateBucket filter = new RelationPredicateBucket();

			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Rowguid == Rowguid);
			filter.PredicateExpression.Add(_PredicateExpression);
			
			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchEntityCollection(_MenuCollection, filter, 0, null, null, PageNumber, PageSize);
			}
			return _MenuCollection;
		}
		
		// Return DataTable
		public DataTable SelectByRowguidRDT(Guid Rowguid)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Rowguid == Rowguid);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, true);
			}
			return toReturn;
		}
		
		// Return DataTable
		public DataTable SelectByRowguidRDT_Paged(Guid Rowguid, int PageNumber, int PageSize)
		{
			DataTable toReturn = new DataTable();
			EntityCollection _MenuCollection = new EntityCollection(new MenuEntityFactory());
			RelationPredicateBucket filter = new RelationPredicateBucket();
			
			IPredicateExpression _PredicateExpression = new PredicateExpression();
			_PredicateExpression.Add(MenuFields.Rowguid == Rowguid);
			filter.PredicateExpression.Add(_PredicateExpression);

			using (DataAccessAdapterBase adapter = (new DataAccessAdapterFactory()).CreateAdapter())
			{
				adapter.FetchTypedList(_MenuCollection.EntityFactoryToUse.CreateFields(), toReturn, filter, 0, null, true, null, PageNumber, PageSize);
			}
			return toReturn;
		}


		
		

	}
}
